package cn.hnu.jpa.bean;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.PersistenceProperty;
import javax.persistence.Transient;

@Entity
public class Person {
	
	
	private String userName;
	
	
	private Integer id;

	private Sex sex = Sex.man;
	
	private String info; //大文本内容
	
	//@Transient   //表示不会保存进数据库  但是放在这里不起作用
	private String notPersistence;//不会保存进数据库
	@Transient  //需要放在get方法上面
	public String getNotPersistence() {
		return notPersistence;
	}

	public void setNotPersistence(String notPersistence) {
		this.notPersistence = notPersistence;
	}

	@Lob
	public String getInfo() {
		return info;
	}

	public void setInfo(String info) {
		this.info = info;
	}

	@Enumerated(EnumType.STRING)//保存的是字符串
	//@Enumerated(EnumType.ORDINAL)  //保存的是下表
	public Sex getSex() {
		return sex;
	}

	public void setSex(Sex sex) {
		this.sex = sex;
	}

	public Person() {
	}

	public Person(String userName,Sex sex) {
		super();
		this.userName = userName;
		this.sex = sex;
	}
	
	@Column (length=20,name="name1",nullable=false,unique=true)
	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}
	
	@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	
	
	
}
